Skip to content

Remove redundant comparison in 32_stonks.py#123

Open
owljacob wants to merge 1 commit intocodedex-io:mainfrom
owljacob:32-stonks
Open

Remove redundant comparison in 32_stonks.py#123
owljacob wants to merge 1 commit intocodedex-io:mainfrom
owljacob:32-stonks

Conversation

@owljacob
Copy link

@owljacob owljacob commented Jun 16, 2025

The code for min_price can be improved by removing redundant comparison.

def min_price(a, b):
  mn = price_at(a)
  for i in range(a, b + 1):
    mn = min(mn, price_at(i))
  return mn

mn is initialized with the value of price_at(a) and that, however, means that the line where mn is updated becomes mn = min(price_at(a), price_at(a)), this is redundant and it's possible to skip it.

@owljacob owljacob changed the title Update 32_stonks.py Remove redundant comparison in 32_stonks.py Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant